package com.zmytest.many2many;

import com.zmytest.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import java.util.List;

/**
 * Created on 2018/12/24.
 *
 * @author zhangmingyu
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
public class Role extends BaseModel<Integer>{

    private String name;

    @ManyToMany
    @JoinTable(
            name = "role_permission",
            joinColumns = {@JoinColumn(name = "role_id")},
            inverseJoinColumns = {@JoinColumn(name = "permission_id")}
    )
    private List<Permission> permissions;


    public Role(){}

    public Role(String name){
        this.name =name;
    }
}
